package cn.iocoder.ny.module.mall.service.impl;

import cn.hutool.extra.qrcode.QrCodeUtil;
import cn.hutool.extra.qrcode.QrConfig;
import cn.iocoder.ny.module.mall.service.IMallQRCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.File;
import java.io.OutputStream;

@Service
public class MallQRCodeServiceImpl implements IMallQRCodeService {


    @Override
    public void generateFile(String content, File file) {
        //生成到本地文件
        QrConfig qrConfig = new QrConfig();
        QrCodeUtil.generate(content, qrConfig, file);
    }

    @Override
    public void generateStream(String content, OutputStream outputStream) {
        //输出到流
        QrConfig qrConfig = new QrConfig();
        QrCodeUtil.generate(content, qrConfig, "png", outputStream);
    }


}
